#include <bits/stdc++.h>
#define int long long
#define L first
#define R second
using namespace std;
const int N=1e5+10;
const double eps=1e-8;
int n,m;
double L,V;
double d[N],v[N],a[N];
double p[N];
double s[N],t[N];//the pos into exceed or out of exceed
int l[N],r[N];//the robot can check
vector<pair<int,int> >S;
bool cmp(pair<int,int>x,pair<int,int>y) {
    return x.R<y.R;
}
void solve() {

    S.clear();

    cin>>n>>m>>L>>V;
    for(int i=1;i<=n;i++)cin>>d[i]>>v[i]>>a[i];
    for(int i=1;i<=m;i++)cin>>p[i];

    for(int i=1;i<=n;i++) {
        if(abs(a[i]-0)<eps) {
            if(v[i]>V)s[i]=d[i],t[i]=L;
            else s[i]=-1;
        } else if(a[i]>0) {
            if(v[i]>V)s[i]=d[i],t[i]=L;
            else s[i]=d[i]+(V*V-v[i]*v[i])/(2*a[i])+eps,t[i]=L;
        } else if(a[i]<0) {
            if(v[i]>V)s[i]=d[i],t[i]=d[i]+(V*V-v[i]*v[i])/(2*a[i])-eps;
            else  s[i]=-1;
        }
        if(s[i]>L||s[i]>t[i])s[i]=-1;
        if(t[i]>L)t[i]=L;
        //cout<<s[i]<<" "<<t[i]<<endl;

    }

    int ans1=0;
    for(int i=1;i<=n;i++) {
        if(s[i]==-1)continue;
        l[i]=lower_bound(p+1,p+m+1,s[i])-p;
        r[i]=upper_bound(p+1,p+m+1,t[i])-p-1;
        if(l[i]<=r[i]) {
            ans1++;
            S.push_back({l[i],r[i]});
            //cout<<l[i]<<" "<<r[i]<<endl;
        }
    }
    sort(S.begin(),S.end(),cmp);
    int las=-1,cnt=0;
    for(int i=0;i<S.size();i++) {
        if(S[i].L>las)las=S[i].R,cnt++;
    }
    cout<<ans1<<" "<<m-cnt<<endl;
    return;
}
signed main() {
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int t;
    cin>>t;
    while(t--)solve();
    return 0;
}
/*
1
5 5 15 3
0 3 0
12 4 0
1 1 4
5 5 ‐2
6 4 ‐4
2 5 8 9 15
*/
